import config from '../config/config';
import request from '../utils/request';

let service = {};

// 店铺商品列表
service.querystorelist = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.querystorelist;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}
// 店铺详情
service.querystoreinfo = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.querystoreinfo;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//买家店铺浏览记录
service.historystore = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.historystore;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    }
  });
}

//1.9新人领取红包
service.receiveaj = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.receiveaj;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//2.0活动红包
service.getBountyBonus = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getBountyBonus;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//2.0特惠商品列表
service.getcheap_goods= (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getcheap_goods;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//2.0特惠商品活动状态
service.cheap_status= (param, cb, ca) => {
  param = param || {};
  let requestUrl = config.api.cheap_status;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    complete: res => {
      if (ca && (typeof ca) == 'function') {
        ca(res);
      }
    }
  });
}

//根据id获取买家信息
service.customerInfo = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.customerInfo;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}
//分享店铺图片
service.getstore_share = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getstore_share;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//买家今日热销商品
service.customerRecommend= (param, cb) => {
  param = param || {};
  let requestUrl = config.api.customerRecommend;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

module.exports = service;